<?php

error_reporting(0);

// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
    
defined('DS')
	|| define('DS', DIRECTORY_SEPARATOR);

defined('PS')
	|| define('PS', PATH_SEPARATOR);

defined('WEB_ROOT')
	|| define('WEB_ROOT', dirname(__FILE__));
	
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path(),
)));

// please don't store following options to application.php, because when user try to install,
// The installer can not save these options to application.php
// (it replace APPLICATION_PATH with real path)
$options = array(
    'bootstrap' => array(
        'path' => APPLICATION_PATH . DS . 'Bootstrap.php',
        'class' => 'Bootstrap',
    ),
    'autoloadernamespaces' => array(
        'vlib' => 'Vlib_',
    ),
    'resources' => array(
            'frontController' => array(
                'moduleDirectory' => APPLICATION_PATH . "/modules",
                'moduleControllerDirectoryName' => "controllers",
                'params' => array('displayExceptions' => 1)
            )
     )
);

/** Zend_Application */
require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.php'
);

$options = $application->mergeOptions($application->getOptions(), $options);
$application->setOptions($options)
            ->bootstrap()
            ->run();